# Makefile.am
#
# Keepalived OpenSource project.
#
# Copyright (C) 2001-2017 Alexandre Cassen, <acassen@gmail.com>

export			DEBUG_CFLAGS
export			DEBUG_CPPFLAGS
export			DEBUG_LDFLAGS

edit = echo "  EDIT     $@"; \
	 sed -e "/^\[\!\[/d"

SUBDIRS			= lib keepalived doc

if BUILD_GENHASH
  SUBDIRS		+= genhash
endif

SUBDIRS			+= bin_install

EXTRA_DIST		= AUTHOR CONTRIBUTORS snap README.md build_setup

doc_DATA		= README

MOSTLYCLEANFILES	= README

MAINTAINERCLEANFILES	= @MAINTAINERCLEANFILES@

README:	$(srcdir)/README.md
	@$(edit) '$(srcdir)/$@.md' >$@

distclean-local:
	@rm -f aclocal.m4 ar-lib compile depcomp install-sh missing keepalived-$(VERSION).tar.gz config.log config.status
	@rm -rf autom4te.cache

dist-hook:
	@rm -f $(distdir)/README

.PHONY: docker
docker:
	docker build -t keepalived .

# clean all files that are generated by automake/autoconf etc
autoclean:
	@$(MAKE) distclean
	@rm -f configure `find . -name Makefile.in` lib/config.h.in lib/git-commit.h

git-clean:
	@$(MAKE) autoclean

clean-local: clean-local-snap

# clean files that are generated by snapcraft
.PHONY:	clean-local-snap
clean-local-snap:
	-rm -rf parts/ prime/ stage/ keepalived_*.snap

# Added targets to maintain compatibility with keepalived releases 1.2.22 and earlier
.PHONY: tarball rpm debug profile mrproper

tarball: dist

@RPM_TRUE@rpm:
@RPM_TRUE@			@$(MAKE) dist
@RPM_TRUE@			@cp -p keepalived-$(VERSION).tar.gz `rpm --eval "%{_sourcedir}"`
@RPM_TRUE@@RPM_BIP_TRUE@	rpmbuild -ba --build-in-place keepalived.spec
@RPM_TRUE@@RPM_BIP_FALSE@	rpmbuild -ba keepalived.spec

debug:
	@$(MAKE) DEBUG_LDFLAGS=-ggdb

profile:
	@$(MAKE) DEBUG_CFLAGS=-pg

mrproper:
	@echo Please use `make distclean`

AM_DISTCHECK_CONFIGURE_FLAGS = \
        --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
